Skip to content

[ZH] Implement the system time and simulation timer within InGameUI #1170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Mauller
Copy link

@Mauller Mauller commented Jun 22, 2025

This PR implements the system clock and simulation timer. Both can be stylised and moved by adding the relevant fields to the inGameUi.ini file.

The system time is just currently offset from the left while the simulation timer is positions based on a percentage of the current horizontal resolution, this is how the game timers are positioned on screen as well.

They are enabled by default for now, but can also be disabled in the options.ini and the code has been setup for future expansion for when the options menu gets expanded to include new features.

The following will disable them independently if added to the options.ini

SimulationTimerEnabled = no
SystemTimeEnabled = no

EDIT: Updated example with latest version
EDIT2: Updated once more with the now grey frame string
Example:
image

TODO

  • Test system time with -quickstart
  • Replicate in Generals

@Mauller Mauller self-assigned this Jun 23, 2025
@Mauller Mauller added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Jun 23, 2025
@xezon xezon added this to the Important features milestone Jun 23, 2025
@xezon
Copy link

xezon commented Jun 23, 2025

The placement of the right side timer is not optimal.

What are the options of fonts here?

GenTool uses the "Tahoma" font for its top screen texts, starting with a size of 8. I do wonder if it would make sense to use that font again, to present it with a familiar look for legacy players.

@Caball009
Copy link

@Mauller
Copy link
Author

Mauller commented Jun 24, 2025

The placement of the right side timer is not optimal.

What are the options of fonts here?

GenTool uses the "Tahoma" font for its top screen texts, starting with a size of 8. I do wonder if it would make sense to use that font again, to present it with a familiar look for legacy players.

Everything is based off position from the left side of the screen, i just replicated what the weapon timers were doing by using a percentage of screen * current horizontal resolution. At 4:3 the simulation timer is just shy of touching the right side of the screen edge.

I can make it relative to the right side of the screen HorizontalResolution - StartOfTextPosition, the annoying part is you can't easily determine the width of the string to adjust for different font sizes.

The font can be whatever we want it to be, i just chose Ariel as it matches the other fonts of the ui message text and weapon timers.

@Mauller
Copy link
Author

Mauller commented Jun 24, 2025

Ah it actually ends up being roughly 4 pixels per character as we have a fixed layout.

This gives an idea of what it should be if you input 00:00:00 it works out at 3.87 pixels per point size.
https://webutility.io/pixel-width-calculator

EDIT: Actually it's not that straightforward, it can vary and be over or under.
EDIT2: Might just have to use the fixed width size of characters based on the point size to give it a max width https://websemantics.uk/tools/font-size-conversion-pixel-point-em-rem-percent/

@xezon
Copy link

xezon commented Jun 24, 2025

In GenTool I have a function to get the extent for font + text to get its width and height. With this information, refined positioning is possible.

@Mauller
Copy link
Author

Mauller commented Jun 24, 2025

I could add the functionality to the display string class so it can return the area the current string covers.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from aead4da to e471c53 Compare June 25, 2025 16:42
@Mauller
Copy link
Author

Mauller commented Jun 25, 2025

Just a rebase with recent main before making relevant changes.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from e471c53 to 3b89ec9 Compare June 25, 2025 17:07
@Mauller
Copy link
Author

Mauller commented Jun 25, 2025

Updated with recent changes, the sim timer is anchored relative to the right of the screen, so adjusting the x coordinate will shift it left instead of right.

Also updated to use Tohama as the default font at 8 point.

image

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 3b89ec9 to d45833d Compare June 25, 2025 18:02
@Mauller
Copy link
Author

Mauller commented Jun 25, 2025

Updated with Tahoma set to bold and rebased with last 5 pushes to main.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from d45833d to 907d2e4 Compare June 26, 2025 17:14
@Mauller
Copy link
Author

Mauller commented Jun 26, 2025

Rebased with main and updated the colour of the frame string to be the same grey as Gentools

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 907d2e4 to 7dfec20 Compare June 28, 2025 19:31
@Mauller
Copy link
Author

Mauller commented Jun 28, 2025

Made an update covering most points.

@@ -876,6 +876,21 @@ const FieldParse InGameUI::s_fieldParseTable[] =
{ "ClearMinesRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_CLEARMINES] ) },
{ "AmbulanceRadiusCursor", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( InGameUI, m_radiusCursors[ RADIUSCURSOR_AMBULANCE] ) },

// TheSuperHackers @info ui enhancement configuration
{ "SystemTimeFont", INI::parseAsciiString, NULL, offsetof( InGameUI, m_systemTimeFont ) },
{ "SystemTimePointSize", INI::parseInt, NULL, offsetof( InGameUI, m_systemTimePointSize ) },
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the point size can go into the Options.ini. GenTool also allows to customize the size.

And then we do not need the ShowSystemTime option, because setting SystemTimePointSize to 0 already implies that it is not shown.

Copy link
Author

@Mauller Mauller Jun 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would also mean making it an option to change the font size in the options menu when that time comes around, instead of it just being a toggle on and off.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well even with the font size it could still be a toggle option. Off would mean font size 0, on would mean font size N. I think it is not necessary to have a "show" option if the point size itself already can say whether it is shown.

Users will ask for being able to make the font smaller, so this is inevitable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaked it so that the font size is controlled in the options and removed adjusting it from the ingameui.ini

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 7dfec20 to 44ee55a Compare June 29, 2025 09:48
@Mauller
Copy link
Author

Mauller commented Jun 29, 2025

Updated with recent suggestions

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from 44ee55a to 5be13ba Compare June 29, 2025 15:18
@Mauller
Copy link
Author

Mauller commented Jun 29, 2025

Reworked based on recent suggestions

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch 2 times, most recently from 3c09aac to eff725d Compare July 4, 2025 20:00
@Mauller
Copy link
Author

Mauller commented Jul 4, 2025

Pushed with the postWindowDraw tweak added. should be good

Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more small things.

TimeString.format(L"%2.2d:%2.2d:%2.2d", systemTime.wHour, systemTime.wMinute, systemTime.wSecond);
Int adjustedSystemTimeFontSize = TheGlobalLanguageData->adjustFontSize(m_systemTimePointSize);
GameFont* systemTimeFont = TheWindowManager->winFindFont(m_systemTimeFont, adjustedSystemTimeFontSize, m_systemTimeBold);
m_systemTimeString->setFont(systemTimeFont);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setup is done every frame. This can be optimized by moving display string creation and setup to the constructor or init function. Can create a pair to freeCustomUiResources.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want people to be able to change the font size dynamically from the options menu then it will need to be setup every frame.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The settings in the Options Menu are applied when pressing ACCEPT, which calls a function. In this function we will then be able to call

freeCustomUiResources();
createCustomUiResources();

or

refreshCustomUiResources();

to rescale the texts.

This would then also need to be done after the Display Resolution has changed.

@Mauller Mauller force-pushed the feature-systime-and-simtimer branch from eff725d to 699612e Compare July 6, 2025 14:42
@Mauller
Copy link
Author

Mauller commented Jul 6, 2025

Had to add an extra check when drawing the game time as the quickstart menu is not considered ingame and is not considered the shellmap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add game time display
4 participants